﻿using System;
using System.Collections.Generic;
using NodeSource.Executor;
using NodeSource.Result;

namespace NodeSource.DataProvider.Cache
{
    public class CacheDataProvider : IDataProvider
    {
        #region IDataProvider Members

        public DataProviderType DataProviderType
        {
            get { return DataProviderType.Cache; }
        }

        public bool Open()
        {
            return true;
        }

        public bool Close()
        {
            return true;
        }

        public bool IsActive()
        {
            return true;
        }

        public Result.ResultSet Query(Executor.Query query)
        {
            var table = new Table
                            {
                                Name = "Client"
                            };
            table.Columns.Add(new Column
            {
                Name = "ClientName",
                FieldType = FieldType.Varchar
            });
            table.Columns.Add(new Column
            {
                Name = "ClientId",
                FieldType = FieldType.Int
            });

            var row = table.NewRow();
            row.SetValue("ClientName", "RBS");
            row.SetValue("ClientId", 1);

            return new ResultSet
                       {
                           Name = "Cache",
                           IsSuccess = true,
                           Tables = new List<Table>
                                        {
                                            table
                                        }
                       };
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            
        }

        #endregion


        public bool CanBeQueriedInGroup
        {
            get { throw new NotImplementedException(); }
        }
    }
}
